package cn.yuemouren.collection.set;

import cn.yuemouren.collection.Set;
import cn.yuemouren.tree.bst.BinarySearchTree;

/**
 * @Author: Timi
 * @Description: 二分搜索树实现set集合
 * @Date: 2020/6/18 9:18
 */
public class BSTSet<T extends Comparable<T>> implements Set<T>{

    private BinarySearchTree<T> binarySearchTree;

    public BSTSet() {
        binarySearchTree = new BinarySearchTree<>();
    }

    @Override
    public int getSize() {
        return binarySearchTree.getSize();
    }

    @Override
    public boolean isEmpty() {
        return binarySearchTree.isEmpty();
    }

    @Override
    public void add(T t) {
        binarySearchTree.add(t);
    }

    @Override
    public void remove(T t) {
        binarySearchTree.remove(t);
    }

    @Override
    public boolean comtains(T t) {
        return binarySearchTree.contains(t);
    }
}
